<template>
	<gui-page ref="guiPage" :customHeader="true">
		<!-- 导航 -->
		<template v-slot:gHeader>
			<nav-bar-custom left-icon="left" :title="$t('materials.priority')" scanType="0"></nav-bar-custom>
		</template>
		<template v-slot:gBody>
			<view class="distributed">
				<view class="gui-bg-white gui-dark-bg-level-3 gui-padding-x distributed-head">
					<view class="header">
						<img class="imgs" src="../../static/set/sort.png" />
						<view>{{ $t('materials.priority') }}</view>
					</view>
					<!-- <view class="rank-list">
						<view class="list-item" style="color:#909399">
							<view style="flex:0 0 25%">{{ $t('materials.orderOfFeeding') }}</view>
							<view style="flex:0 0 40%">{{ $t('materials.feedingCode') }}</view>
							<view style="flex:0 0 35%">{{ $t('materials.feedingOfQty') }}</view>
						</view>
						<view class="list-item" style="padding:10rpx 0 10rpx 0" v-for="i in 5" :key="i">
							<view style="flex:0 0 25%">
								<view class="number">{{ i }}</view>
							</view>
							<view style="flex:0 0 40%">
								<view class="materialCode">{{ '61AF000' + i }}</view>
							</view>
							<view style="flex:0 0 35%">
								<view class="qtys">{{ 25 + i }} pcs</view>
							</view>
						</view>
					</view> -->
				</view>
				<scroll-view :show-scrollbar="false" :scroll-y="true" class="scroll" @scrolltolower="scrolltolowerFn">
					<view style="height: 15rpx"></view>
					<view class="card-boxCustom" style="padding:12rpx  16rpx 8rpx 16rpx" v-for="(x, i) in data.list"
						:key="i">
						<view class="custom-card-title" style="padding:12rpx 0">
							<text class="title-line " style="background:#659f2c"></text>
							<text class="orderOfFeeding">{{ $t('materials.orderOfFeeding') }}：</text>
							<text class="orders">{{ i + 1 }} </text>
						</view>
						<view class="card-body" style="padding: 12rpx 0;">
							<view class="card-body-item">
								<text class="body-item-title">{{ $t('materials.feedingCode') }}：</text>
								<text class="feedingCode">{{x.materialCode}}</text>
							</view>
							<view class="card-body-item" style="padding: 12rpx 0;">
								<text class="body-item-title">{{ $t('materials.feedingOfQty') }}：</text>
								<text class="card-number qty">{{x.lvtUnmetQty+'pcs / ' + 0.01+'tray'}}</text>
							</view>
							<view class="card-body-item" style="padding: 12rpx 0;">
								<text class="body-item-title">{{ $t('smashRemoval.salesOrderN')
								}}：</text>{{x.soCode}}
							</view>
							<view class="card-body-item" style="padding: 12rpx 0;">
								<text class="body-item-title">{{ $t('materials.salesQuantity') }}：</text>
								<text class="card-number">{{x.salesQty }}{{$t('materials.box') }}</text>
							</view>
							<view class="card-body-item" style="padding: 12rpx 0;">
								<text class="body-item-title">{{ $t('materials.dateOfDelivery') }}：</text>{{dateFormat(x.deliveryDate)}}
							</view>
						</view>
					</view>
					<view v-if="data.noticeHooks" class="noticeHooks">
						{{ data.list.length == 0 ? $t('locationBarcodeInfo.fulfilledAvailable') : $t('stockManage.without') }}
					</view>
				</scroll-view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
	import {
		onShow
	} from '@dcloudio/uni-app';
	import {
		useI18n
	} from 'vue-i18n';
	import {
		ref,
		reactive,
		onMounted
	} from 'vue';
	import {
		useStore
	} from "vuex";
	import {
		getLvtInfo
	} from '@/api/api.js'
	let store = useStore();
	const {
		t
	} = useI18n();

	const data = reactive({
		noticeHooks: false,
		isFinish: false,
		isLoading: false,
		list: [],
		page: 1,
		rows: 20
	})

	onMounted(() => {
		lvtInfo()
	})

	// 下拉加载
	const scrolltolowerFn = () => {
		if (!data.isFinish && !data.isLoading) {
			data.page++
			data.isLoading = true;
		}
	}

	const lvtInfo = () => {
		getLvtInfo().then(res => {
			// console.log(res)
			data.list = res.上料优先级
			if(data.list.length == 0){
				data.noticeHooks=true
			}else{
				data.noticeHooks
			}
		})
	}

    //格式化时间
	const dateFormat = (time) => {
		let date = new Date(time);
		let year = date.getFullYear();
		// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
		let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
		let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
		let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
		let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
		let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
		// 拼接
		 return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
		//return year + "-" + month + "-" + day;
	}
</script>

<style lang="scss" scoped>
	.distributed {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		height: calc(100vh - 88rpx);
	}

	.distributed-head {
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
	}

	.header {
		height: 60rpx;
		width: 100%;
		font-size: 32rpx;
		font-weight: 700;
		box-sizing: border-box;
		line-height: 60rpx;
		display: flex;
		flex-direction: row;
		color: #659f2c;
		padding: 10rpx 0 0 0;
		margin-bottom: 10px;

		.imgs {
			height: 50rpx;
			width: 50rpx;
		}
	}

	.rank-list {
		padding: 6rpx 10rpx 10rpx 20rpx;

		.list-item {
			display: flex;
			flex-direction: row;
			text-align: center;
			border-bottom: 2px dashed #eee;
			line-height: 60rpx;
			color: #909399;
			align-items: center;
			font-size: 28rpx;
			text-align: center;

			.number {
				// flex: 0 0 20px;
				width: 40rpx;
				height: 30rpx;
				font-size: 24rpx;
				line-height: 30rpx;
				border-radius: 15%;
				color: #fff;
				background-color: rgb(64, 158, 255);
				margin-left: 60rpx;
			}

			.materialCode {
				width: 120rpx;
				height: 30rpx;
				border: #c4ebb2 2rpx solid;
				font-size: 24rpx;
				margin-left: 60rpx;
				color: #61c430;
				padding: 0 10rpx;
				border-radius: 10rpx;
				line-height: 30rpx;
			}

			.qtys {
				width: 120rpx;
				height: 30rpx;
				border: #e9e9eb 2rpx solid;
				font-size: 24rpx;
				margin-left: 40rpx;
				color: #909399;
				padding: 0 14rpx;
				border-radius: 10rpx;
				line-height: 30rpx;
				background-color: #f4f4f5;
			}
		}
	}



	.scroll {
		flex: 1;
		height: 2rpx;

		.orderOfFeeding {
			color: #659f2c;
		}

		.orders {
			width: 40rpx;
			height: 30rpx;
			font-size: 24rpx;
			line-height: 30rpx;
			border-radius: 15%;
			color: #fff;
			background-color: rgb(64, 158, 255);
			text-align: center;
		}

		.feedingCode {
			width: 120rpx;
			height: 30rpx;
			border: #c4ebb2 2rpx solid;
			font-size: 24rpx;
			color: #61c430;
			padding: 0 14rpx;
			border-radius: 10rpx;
			line-height: 30rpx;
		}

		.card-number {
			width: 120rpx;
			height: 30rpx;
			border: #e9e9eb 2rpx solid;
			font-size: 24rpx;
			color: #909399;
			padding: 0 14rpx;
			border-radius: 10rpx;
			line-height: 30rpx;
			background-color: #f4f4f5;
			text-align: center;
		}

		.qty {
			width: 200rpx;
			height: 30rpx;
			border: #a0cfff 2rpx solid;
			font-size: 24rpx;
			color: #409eff;
			padding: 0 14rpx;
			border-radius: 10rpx;
			line-height: 30rpx;
		}
	}
</style>
